﻿using System;
using System.Windows.Forms;
using Microsoft.Office.PowerPoint.STAMP.Presenter;
using Microsoft.Office.PowerPoint.STAMP.View;

namespace Microsoft.Office.PowerPoint.STAMP
{
    public partial class Progress : Form, IProgressView
    {
        private readonly ProgressPresenter _presenter;

        public Progress(int max)
        {
            InitializeComponent();

            ProgressBarMaximum = max;
            _presenter = new ProgressPresenter(this);
        }

        public void UpdateCreating(int progress)
        {
            _presenter.UpdateCreating(progress);
            Refresh();
        }

        public void UpdateDeleting(int progress)
        {
            _presenter.UpdateDeleting(progress);
            Refresh();
        }

        public void Update(int progress, string stage)
        {
            if (progress != 0)
            {
                _presenter.Update(progress, stage);
                Refresh();
            }
        }

        private void Busy_Load(object sender, EventArgs e)
        {
            // centerparent not workin for a ".Show" form, 
            // so set position manually.
            if (this.Owner != null)
            {
                this.Location = new System.Drawing.Point(
                    this.Owner.Location.X +
                    (this.Owner.Width - this.Width) / 2,
                    this.Owner.Location.Y +
                    (this.Owner.Height - this.Height) / 2);
            }
        }

        public string Description
        {
            get { return lblDescription.Text; }
            set { lblDescription.Text = value; }
        }

        public int ProgressBarValue
        {
            get { return progressBar1.Value; }
            set { progressBar1.Value = value; }
        }

        public int ProgressBarMaximum
        {
            get { return progressBar1.Maximum; }
            set { progressBar1.Maximum = value; }
        }
    }
}
